package com.ericsson.resourceplanner.service.impl;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.ericsson.resourceplanner.dao.ReportDataDAO;
import com.ericsson.resourceplanner.dao.entity.Report;
import com.ericsson.resourceplanner.dao.impl.ReportDataDaoImpl;
import com.ericsson.resourceplanner.service.ReportService;

@Service
public class ReportServiceImpl implements  ReportService {
	
	
	 @Autowired
	
	private ReportDataDAO reportDataDAO ;

	
	 
	 
	 
	 
	 
	 @Override
	public List<Report> getUtilReport(String month , String year) {
		// TODO Auto-generated method stub
		 Map<String,List<String>> manualEntryMap = new HashMap<String, List<String>>();
		List <Report> list = reportDataDAO.getUtilisationReport(month,year);
		 Set<String> set_temp = ReportDataDaoImpl.manualFlagY_set;
		  if(set_temp!=null){
			 System.out.println("Set_size:"+set_temp.size());
				for(String set :set_temp){
					String  signum = set.substring(0, 7);
					String week_no = set.substring(7, 8);
					System.out.println("Signum week:"+signum+":"+week_no);
					List<String> wk_list = manualEntryMap.get(signum);
					 if(wk_list!=null && wk_list.size()>0 ){
						 wk_list.add(week_no);
					 }
					 else{
						 List<String> week_list = new  ArrayList<String>(); 
						 week_list.add(week_no);
						 manualEntryMap.put(signum, week_list);
					 }
					
				}
			}
		return list;
		
	  }

	public ReportDataDAO getReportDataDAO() {
		return reportDataDAO;
	}

	public void setReportDataDAO(ReportDataDAO reportDataDAO) {
		this.reportDataDAO = reportDataDAO;
	}

}
